package com.ruoyi.hr.controller.hr.empInfo;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.service.AuthorityService;
import com.ruoyi.hr.service.empinfo.IncumbencyEmpService;
import com.ruoyi.hr.service.empinfo.OftenQueryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * @author zeo
 * @explain 常用查询
 * @date 2020/4/6
 */
@Controller
@RequestMapping("empInfo/oftenQuery")
public class OftenQueryController extends BaseController {

    @Autowired
    OftenQueryService oftenQueryService;

    @Autowired
    AuthorityService authorityService;

    private String prefix = "hr/empinfo/oftenquery";

    /**
     * 跳转年龄统计
     */
    @GetMapping("ageStatistics")
    public String ageStatistics() {
        return prefix + "/ageStatistics";
    }

    /**
     * 年龄统计数据
     * @param map
     * @return
     */
    @RequestMapping("/ageStatistics")
    @ResponseBody
    public TableDataInfo ageStatistics(@RequestParam Map map) {
        return getDataTable(oftenQueryService.ageStatistics(map));
    }

    /**
     * 跳转司龄统计
     */
    @GetMapping("siLingStatistics")
    public String siLingStatistics() {
        return prefix + "/siLingStatistics";
    }

    /**
     * 司龄统计数据
     * @param map
     * @return
     */
    @RequestMapping("/siLingStatistics")
    @ResponseBody
    public TableDataInfo siLingStatistics(@RequestParam Map map) {
        return getDataTable(oftenQueryService.siLingStatistics(map));
    }

    /**
     * 跳转工龄统计
     */
    @GetMapping("gongLingStatistics")
    public String gongLingStatistics() {
        return prefix + "/gongLingStatistics";
    }

    /**
     * 工龄统计数据
     * @param map
     * @return
     */
    @RequestMapping("/gongLingStatistics")
    @ResponseBody
    public TableDataInfo gongLingStatistics(@RequestParam Map map) {
        return getDataTable(oftenQueryService.gongLingStatistics(map));
    }


    /**
     * 跳转学历统计
     */
    @GetMapping("xueLiStatistics")
    public String xueLiStatistics() {
        return prefix + "/xueLiStatistics";
    }

    /**
     * 学历统计数据
     * @param map
     * @return
     */
    @RequestMapping("/xueLiStatistics")
    @ResponseBody
    public TableDataInfo xueLiStatistics(@RequestParam Map map) {
        return getDataTable(oftenQueryService.xueLiStatistics(map));
    }

    /**
     * 跳转员工分类统计
     */
    @GetMapping("ygflStatistics")
    public String ygflStatistics() {
        return prefix + "/ygflStatistics";
    }

    /**
     * 员工分类数据
     * @param map
     * @return
     */
    @RequestMapping("/ygflStatistics")
    @ResponseBody
    public TableDataInfo ygflStatistics(@RequestParam Map map) {
        return getDataTable(oftenQueryService.ygflStatistics(map));
    }

    /**
     * 跳转员工分类统计
     */
    @GetMapping("ygydStatistics")
    public String ygydStatistics() {
        return prefix + "/ygydStatistics";
    }

    /**
     * 员工异动数据
     * @param map
     * @return
     */
    @RequestMapping("/ygydStatistics")
    @ResponseBody
    public TableDataInfo ygydStatistics(@RequestParam Map map) {
        return getDataTable(oftenQueryService.ygydStatistics(map));
    }


    /**
     * 跳转组合统计
     */
    @GetMapping("zhtjStatistics")
    public String zhtjStatistics() {
        return prefix + "/zhtjStatistics";
    }


    /**
     * 组合统计
     * @param map
     * @return
     */
    @RequestMapping("/zhtjStatistics")
    @ResponseBody
    public TableDataInfo zhtjStatistics(@RequestParam Map map) {
        return getDataTable(oftenQueryService.zhtjStatistics(map));
    }
    @RequestMapping("/findAllFieldByXflag")
    @ResponseBody
    public List<String> findAllFieldByXflag(String Xflag){
        return oftenQueryService.findAllFieldByXflag(Xflag);
    }

    /**
     * 跳转黑名单查询
     */
    @GetMapping("hmdStatistics")
    public String hmdStatistics() {
        return prefix + "/hmdStatistics";
    }

    /**
     * 黑名单数据
     * @return
     */
    @RequestMapping("/hmdStatistics")
    @ResponseBody
    public TableDataInfo hmdStatistics(@RequestParam Map map) {
        Authority authority = authorityService.findAuthorAndIsAdmin();
        startPage();
        return getDataTable(oftenQueryService.hmdStatistics(map,authority));
    }



}
